// run: $exec < input
#include <iostream>
#include <algorithm>
#include <cstring>

typedef long long ans_type;

struct state
{
	int s;
	ans_type way;
};

int const maxn = 12;
int const max_size = 500000;
int const hash_size = 98317;
bool maze[maxn][maxn];
state now_prev_state[2][max_size];
int hash_head[hash_size];
int hash_next[max_size];
int n, m, now, prev, now_size, prev_size;

inline void hash(int x, ans_type way)
{
	int t = x % hash_size;
	for (int p = hash_head[t]; p; p = hash_next[p])
		if (now_prev_state[now][p].s == x) {
			now_prev_state[now][p].way += way;
			return;
		}

	now_prev_state[now][now_size].s = x;
	now_prev_state[now][now_size].way = way;
	hash_next[now_size] = hash_head[t];
	hash_head[t] = now_size++;
}

inline int get_state(int sta, int x)
{
	return (sta >> (x << 1)) & 3;
}

inline int make(int delta, int x)
{
	return delta * (1 << (x << 1));
}

ans_type plug_dp()
{
	ans_type ret_way = 0;
	prev = 0;
	now = 1;
	prev_size = 0;
	now_size = 1;
	now_prev_state[now][0].s = 0;
	now_prev_state[now][0].way = 1;

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			std::swap(prev, now);
			prev_size = now_size;
			now_size = 0;

			std::memset(hash_head, 0, sizeof(hash_head));

			for (int k = 0; k < prev_size; k++) {
				int sta = now_prev_state[prev][k].s;
				ans_type way = now_prev_state[prev][k].way;

				int pin1 = get_state(sta, j - 1);
				int pin2 = get_state(sta, j);

				if (!maze[i][j]) {
					if (!pin1 && !pin2) hash(sta, way);
					continue;
				}

				if (!pin1 && !pin2) {
					if (j < m && i < n && maze[i + 1][j] && maze[i][j + 1]) {
						sta += make(1, j-1) + make(2, j);
						hash(sta, way);
					}
					continue;
				}

				if (!pin1 || !pin2) {
					if (!pin1 && j < m && maze[i][j + 1])
						hash(sta, way);

					if (!pin2 && i < n && maze[i + 1][j])
						hash(sta, way);

					if (!pin1 && i < n && maze[i + 1][j]) {
						sta += make(pin2, j - 1) - make(pin2, j);
						hash(sta, way);
					}

					if (!pin2 && j < m && maze[i][j + 1]) {
						sta += make(pin1, j) - make(pin1, j - 1);
						hash(sta, way);
					}
					continue;
				}

				sta -= make(pin1, j - 1) + make(pin2, j);

				if (pin1 == pin2) {
					if (pin1 == 1) {
						int top = 1;
						for (int p = j + 1; p <= m; p++) {
							int pin3 = get_state(sta, p);
							if (pin3 == pin1)
								top++;
							else if (pin3 == 3 - pin1)
								top--;
							if (!top) {
								hash(sta - make(1, p), way);
								break;
							}
						}
					} else {
						int top = 1;
						for (int p = j - 2; p >= 0; p--) {
							int pin3 = get_state(sta, p);
							if (pin3 == pin2)
								top++;
							else if (pin3 == 3 - pin2)
								top--;
							if (!top) {
								hash(sta + make(1, p), way);
								break;
							}
						}
					}
					continue;
				}

				if (pin1 == 2) {
					hash(sta, way);
					continue;
				}

				if (i == n && j == m)
				ret_way += way;
			}
		}

		for (int j = 0; j < now_size; j++)
			now_prev_state[now][j].s <<= 2;
	}

	return ret_way;
}

int main()
{
	std::ios::sync_with_stdio(false);
	while (std::cin >> n >> m && (n || m)) {
		for (int i = 1; i <= n; i++)
			for (int j = 1; j <= m; j++) {
				char ch; std::cin >> ch;
				maze[i][j] = ch == '.';
			}
		// init maze, convert to single loop.
		for (int i = 1; i <= m; i++) maze[n + 1][i] = false;
		maze[n + 1][1] = maze[n + 1][m] = true;
		for (int i = 1; i <= m; i++) maze[n + 2][i] = true;
		n += 2;

		std::cout << plug_dp() << '\n';
	}
}

